<h1><?php echo $fund['name'] ?></h1>
<ul id="breadcrumb">
	<li>ใบสำคัญการลงบัญชี</li>			
</ul>
<div id="content">
	<div class="head">
		<p><?php echo $fund['name'] ?></p>
		<p>ใบสำคัญการลงบัญชี</p>
		<p>วันที่ <?php echo db_to_th($rs['voucher_date']) ?></p>
	</div>
	<div class="voucher_number">
		<p>เลขที่ <?php echo $rs['number'] ?></p>
		<p><?php echo ($rs['voucher_type_id']==1)?'ด้านรับ':'' ?>
		<?php echo ($rs['voucher_type_id']==2)?'ด้านจ่าย':'' ?>
		<?php echo ($rs['voucher_type_id']==3)?'ด้านทั่วไป':'' ?></p>
	</div>
	<?php $count = 20 - (count($credits) + count($debits)); ?>
<table class="tbform tbvoucher">
	<tr>
		<th style="width:50%;">ชื่อบัญชี</th>
		<th style="width:16%;">หน้าบัญชี</th>
		<th style="width:17%;" colspan="2">เดบิต</th>
		<th style="width:17%;" colspan="2">เครดิต</th>
	</tr>
	<?php $sum['debit'] = 0 ?>
	<?php $sum['credit'] = 0 ?>
	<?php foreach ($debits as $debit): ?>
	<tr>
		<td class="dr1">
			<?php echo $debit['account_name'] ?>
		</td>
		<td><?php echo $debit['account_code'] ?></td>
		<td class="num"><?php echo number_format($debit['price']) ?></td>
		<td style="width:20px"><?php echo (substr(number_format($debit['price'],2),-2)<>'00')?substr(number_format($debit['price'],2),-2):'' ?></td>
		<td></td>
		<td style="width:20px"></td>
	</tr>
	<?php $sum['debit'] += $debit['price'] ?>
	<?php endforeach; ?>
	<?php foreach ($credits as $credit): ?>
	<tr>
		<td class="cr1">
			<?php echo $credit['account_name'] ?>
			</td>
		<td><?php echo $credit['account_code'] ?></td>
		<td></td>
		<td style="width:20px"></td>
		<td class="num"><?php echo number_format($credit['price']) ?></td>
		<td style="width:20px"><?php echo (substr(number_format($credit['price'],2),-2)<>'00')?substr(number_format($credit['price'],2),-2):'' ?></td>
	</tr>
	<?php $sum['credit'] += $credit['price'] ?>
	<?php endforeach; ?>
	<?php for($i=1;$i<=$count;$i++): ?>
	<tr>
		<td>
			 
			</td>
		<td> </td>
		<td> </td>
		<td style="width:20px"> </td>
		<td class="num"> </td>
		<td style="width:20px"> </td>
	</tr>
	<?php endfor; ?>
	<tr><th colspan="6" style="text-align:left; font-weight:normal;"><strong>คำอธิบาย</strong><br /><br />
	<?php echo ($rs['description'])?nl2br($rs['description']):'-' ?></td></tr>
	<tr>

		<td colspan="6" style="padding:0;">
			<div class="signature">
					<span class="left">ผู้บันทึก</span> 
					<div class="left">
						<hr />
						<p><?php echo $rs['user_firstname'].' '.$rs['user_lastname'] ?></p>
						<p><?php echo $rs['user_position'] ?></p>
					</div>
			</div>
			<div class="signature border">
					<span class="left">ผู้ตรวจสอบ</span> 
					<div class="left">
						<hr />
						<p><?php echo $rs['examiner']?></p>
						<p><?php echo $rs['examiner_position'] ?></p>
					</div>
			</div>
			<div class="signature">
					<span class="left">ผู้อนุมัติ</span> 
					<div class="left">
						<hr />
						<p><?php echo $rs['endorsee']?></p>
						<p><?php echo $rs['endorsee_position'] ?></p>
					</div>
			</div>
			<div class="clear"></div>
		</td>
	</tr>
</table>
<br />
<input class="button" type="button" value="<?php echo lang('btn_back')?>"  onclick="window.location = 'voucher/index/<?php echo $fund['id'] ?>'" />
</div>


